var express = require('express');
var router = express.Router();
const orderController = require('../controllers/order_controller')
const order = require('../models/order_bean')


//添加订单数据
router.post('/addorder', function (req, res) {
    console.log(req.body.data,req.body.address);
    orderController.addorder(new order.add(req.body.data,req.body.address),(ret) =>res.json(ret)
    ,
    (err) => res.json(err)
    )
})



//获取所有订单数据
router.post('/selectall', function (req, res) {
    orderController.getall(new order.add(req.body.page,req.body.size),(ret) =>res.json(ret)
    ,
        (err) => res.json(err)
    )
})

//根据状态查询数据
router.post('/selecstate', function (req, res) {
    orderController.getselect(new order.select(req.body.page,req.body.size,req.body.state),(ret) =>res.json(ret)
    ,
        (err) => res.json(err)
    )
})


//获取订单数据
router.post('/selectorder', function (req, res) {
    orderController.getorder(req.body.orderid,(ret) =>res.json(ret)
    ,
        (err) => res.json(err)
    )
})


//删除订单数据
router.delete('/deleteorder', function (req, res) {
    console.log(req.body.orderid);
   orderController.deleteorder(req.body.orderid,(ret) =>res.json(ret)
    ,
       (err) => res.json(err)
   )
})


//修改数据
router.put('/updataorder', function (req, res) {
    orderController.updateorder(new order.update(req.body.orderid,req.body.date),(ret) =>res.json(ret)
    ,
        (err) => res.json(err)
    )
})












module.exports = router;